package com.example.demo.controller;

import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.example.demo.entity.Goods;
import com.example.demo.service.GoodsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zhangxingchuan
 * @date 2023/6/8 13:30
 */
@RestController
@RequestMapping("/goods")
public class goodsController {
    @Resource
    private GoodsService goodsService;

    @GetMapping("getByAIdTest1")
    public Goods getByAIdTest1(@RequestParam Long id){
        return goodsService.getByAIdTest1(id);
    }
    @GetMapping("getByAIdTest2")
    public Goods getByAIdTest2(@RequestParam Long id){
        return goodsService.getByAIdTest2(id);
    }
    @GetMapping("add")
    @DSTransactional
    public String add(){
        goodsService.addTest1();
        goodsService.addTest2();
        System.out.println(1/0);
        return "";
    }
}
